@@ -272,20 +272,22 @@ bool ConvertTTFToWOFF2(const uint8_t *data, size_t length,
272
272
std::vector<uint8_t > compression_buf (compression_buffer_size);
273
273
uint32_t total_compressed_length = compression_buffer_size;
274
274
275
- // Collect all transformed data into one place.
275
+ // Collect all transformed data into one place in output order .
276
276
std::vector<uint8_t > transform_buf (total_transform_length);
277
277
size_t transform_offset = 0 ;
278
278
for (const auto & font : font_collection.fonts ) {
279
- for (const auto & i : font.tables ) {
280
- const Font::Table* table = font.FindTable (i.second .tag ^ 0x80808080 );
281
- if (i.second .IsReused ()) continue ;
282
- if (i.second .tag & 0x80808080 ) continue ;
279
+ for (const auto tag : font.OutputOrderedTags ()) {
280
+ const Font::Table& original = font.tables .at (tag);
281
+ if (original.IsReused ()) continue ;
282
+ if (tag & 0x80808080 ) continue ;
283
+ const Font::Table* table_to_store = font.FindTable (tag ^ 0x80808080 );
284
+ if (table_to_store == NULL ) table_to_store = &original;
283
285
284
- if (table == NULL ) table = &i.second ;
285
- StoreBytes (table->data , table->length ,
286
+ StoreBytes (table_to_store->data , table_to_store->length ,
286
287
&transform_offset, &transform_buf[0 ]);
287
288
}
288
289
}
290
+
289
291
// Compress all transformed data in one stream.
290
292
if (!Woff2Compress (transform_buf.data (), total_transform_length,
291
293
&compression_buf[0 ],
0 commit comments